<?php
require '../config.php';
require '../libs/class.login.php';
require '../libs/function.php';

$log = new logmein();
$log->checklogin();

$gname = isset($_POST['gname']) ? strval($_POST['gname']) : NULL;
$gname = remove_unicode($gname, true);

if ($gname) {
	// Get record
	$Qry = 'SELECT g_id, g_name
			FROM games
			WHERE g_url LIKE "%' . $gname . '%"';
	$res = $db->fetchAll($Qry);

	if ($res) {
		$games = '<ul>';
		foreach ($res as $key=>$value) {
			$games .= '<li><a href="/admin/?mod=games&act=edit&id=' . $value['g_id'] . '" target="_blank">' . $value['g_name'] . '</a></li>';
		}
		$games .= '</ul>';

		echo $games;
	}
}